package com;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        System.out.println("请输入跳舞轮数");
        Scanner sc=new Scanner(System.in);
        int round=sc.nextInt();
        SeqQueue boys=new SeqQueue(8);
        SeqQueue girls=new SeqQueue(8);
        boys.add("b1");
        boys.add("b2");
        boys.add("b3");
        boys.add("b4");
        girls.add("g1");
        girls.add("g2");
        girls.add("g3");
        int j=0;
        int min=minLength(boys,girls);
        while(j<round) {
            for(int i=0;i<min;i++) {
                String boy = boys.poll();
                String girl = girls.poll();
                System.out.println("boy" + boy + "<-->girls" + girl);
                boys.add(boy);
                girls.add(girl);
            }
            System.out.println("没有被配对的第一个人是："+minSeqQueue(girls , boys).peek());
            j++;
        }
    }
    private static int minLength(SeqQueue a,SeqQueue b) {
        int aLength=a.rear-a.front;
        int bLength=b.rear-b.front;

        if(aLength<bLength) {
            return aLength;
        }else {
            return bLength;
        }
    }
    private static SeqQueue minSeqQueue(SeqQueue a,SeqQueue b) {
        if(a.element.length<b.element.length) {
            return a;
        }else {
            return b;
        }


    }

}
